package com.yequan.spring.ioc.overview.domain;

import com.yequan.spring.ioc.overview.annotation.Super;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @author : Administrator
 * @date : 2020/3/31
 */
@Super
public class SuperUser extends User implements BeanPostProcessor {

    private String address;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "SuperUser{" +
                "address='" + address + '\'' +
                "} " + super.toString();
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        User superUser = null;
        if (bean instanceof User){
            superUser = (User) bean;
            superUser.setName("我后置处理的");
        }
        return superUser;
    }
}
